<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript不支持使用名字来索引数组只允许使用数字索引</title>
</head>

<body>
    <p id="demo"></p>
    <script>
        var person = [];
        person[0] = "john";
        person[1] = "doe";
        person[2] = 46;
        document.getElementById("demo").innerHTML =
            person[0] + " " + person.length;
    </script>
</body>

</html>